<?php

// [ 路演活动 ]

namespace app\common\validate;
use think\Validate;

class Activity extends Validate
{
    // 验证规则
    protected $rule = [
        'id'           => 'require|integer|max:11',
        'type'         => 'require|integer|in:0,1',
        'title'        => 'require|length:4,80',
        'cover'        => 'require|max:256',
        'introduction' => 'require|max:8000',
        'localtion'    => 'require|length:2,40',
        'address'      => 'require|length:2,80',
        'organizers'   => 'require|length:2,40',
        'sign_up_url'  => 'max:256',
        'start_time'   => 'require|date',
        'end_time'     => 'require|date',
    ];

    // 错误提示
    protected $message = [
        'id.require'           => '活动主键必须',
        'id.integer'           => '活动主键必须为数字',
        'id.max'               => '活动主键最大长度[11]',
        
        'type.require'         => '类型必须',
        'type.integer'         => '类型必须为数字',
        'type.in'              => '类型取值范围[0|1]',
        
        'title.require'        => '名称必须',
        'title.length'         => '名称长度[4~40]',
        
        'cover.require'        => '封面必须',
        'cover.max'            => '封面最大长度[256]',
        
        'introduction.require' => '简介必须',
        'introduction.max'     => '简介最大长度[8000]',
        
        'localtion.require'    => '地点必须',
        'localtion.length'     => '地点长度[4~40]',
        
        'address.require'      => '详细地址必须',
        'address.length'       => '详细地址长度[4~80]',
        
        'organizers.require'   => '主办方必须',
        'organizers.length'    => '主办方长度[4~40]',
        
        'sign_up_url.max'      => '报名链接最大长度[256]',
        
        'start_time.require'   => '开始时间必须',
        'start_time.date'      => '开始时间格式不合法',
        
        'end_time.require'     => '结束时间必须',
        'end_time.date'        => '结束时间格式不合法',
    ];
    
    // 验证场景
    protected $scene = [
        // 管理员登录
        'add'  => ['type','title','cover','introduction','localtion','address','organizers','sign_up_url','start_time','end_time'],
        // 管理员修改密码
        'edit' => ['id','type','title','cover','introduction','localtion','address','organizers','sign_up_url','start_time','end_time'],
    ];
}